package com.aurora.oa.model;

import android.util.Log;

import com.aurora.oa.Constants.AuroraConstants;
import com.aurora.oa.application.MyApplication;
import com.aurora.oa.bean.HttpResult;
import com.aurora.oa.listener.OnAddContactsGroupListener;
import com.aurora.oa.listener.OnAddGroupMemberListener;
import com.aurora.oa.listener.OnAddTeamListener;
import com.aurora.oa.listener.OnAddTeamMemberListener;
import com.aurora.oa.listener.OnGetApproveDetailListener;
import com.aurora.oa.listener.OnGetMyContactsGroupListListener;
import com.aurora.oa.listener.OnGetMyContactsListListener;
import com.aurora.oa.listener.OnGetMyTeamListListener;
import com.aurora.oa.listener.OnGetMyTeamMemberListListener;
import com.aurora.oa.listener.OnGetUserInfoListener;
import com.aurora.oa.listener.OnRequestApplyListListener;
import com.aurora.oa.listener.OnRequestApproveListListener;
import com.aurora.oa.listener.OnRequestArticalDetailListener;
import com.aurora.oa.listener.OnRequestAttendancePersonListener;
import com.aurora.oa.listener.OnRequestCarHistoryListener;
import com.aurora.oa.listener.OnRequestCarListListener;
import com.aurora.oa.listener.OnRequestCompanyStructureDataListener;
import com.aurora.oa.listener.OnRequestDailyDataListener;
import com.aurora.oa.listener.OnRequestExpenceDetailListener;
import com.aurora.oa.listener.OnRequestFileListListener;
import com.aurora.oa.listener.OnRequestHttpDataListener;
import com.aurora.oa.listener.OnRequestIsSuccessListener;
import com.aurora.oa.listener.OnRequestLogDetailListener;
import com.aurora.oa.listener.OnRequestLogListDataListener;
import com.aurora.oa.listener.OnRequestNoticeDetailListener;
import com.aurora.oa.listener.OnRequestNoticeListListener;
import com.aurora.oa.listener.OnRequestPatrolShopListListener;
import com.aurora.oa.listener.OnRequestPatrollogDetailListener;
import com.aurora.oa.listener.OnRequestPatrollogListListener;
import com.aurora.oa.listener.OnRequestTrackHistoryListener;
import com.aurora.oa.listener.OnSendLogListener;
import com.aurora.oa.listener.OnSendPatrollogListener;
import com.aurora.oa.listener.OnUploadAttachmentListener;
import com.aurora.oa.listener.OnUploadFeedbackListener;
import com.aurora.oa.login.model.LoginResultData;
import com.aurora.oa.listener.OnLoginListener;
import com.aurora.oa.login.model.UserInfo;
import com.aurora.oa.message.bean.ResponseFileID;
import com.aurora.oa.mycenter.bean.ContactsBean;
import com.aurora.oa.mycenter.bean.MyContactsGroupBean;
import com.aurora.oa.mycenter.bean.TeamBean;
import com.aurora.oa.mycenter.bean.TeamMemberBean;
import com.aurora.oa.signin.bean.TrackHistoryBean;
import com.aurora.oa.utils.MD5Util;
import com.aurora.oa.utils.SharedPreferencesUtil;
import com.aurora.oa.work.bean.ApplyCarHistoryBean;
import com.aurora.oa.work.bean.ApplyListBean;
import com.aurora.oa.work.bean.ApproveDataBean;
import com.aurora.oa.work.bean.ApproveListBean;
import com.aurora.oa.work.bean.CompanyStructureBean;
import com.aurora.oa.work.bean.DailyDataBean;
import com.aurora.oa.work.bean.ExpenceBean;
import com.aurora.oa.work.bean.FileBean;
import com.aurora.oa.work.bean.NoticeBean;
import com.aurora.oa.work.bean.PatrolShopListBean;
import com.aurora.oa.work.bean.PatrollogBean;
import com.aurora.oa.work.bean.PatrollogListBean;
import com.aurora.oa.work.bean.SendLogBean;
import com.aurora.oa.work.bean.SendPatrollogBean;
import com.aurora.oa.work.bean.WorkLogDataBean;
import com.aurora.oa.work.model.ApplyCarBean;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.File;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import okhttp3.Call;

/**
 * Created by Administrator on 2017/3/17 0017.
 */
public class RequestHttpModelImpl implements RequestHttpModel{
    String TAG = "net_info";
    //app的访问Key
    public static final String APP_KEY = "6UyYIhZR906DREYjTsoreWQWuJHubBGI";
    public static final String PARAMKEY_APP_KEY = "appKey";
    //app的访问密钥
    public static final String APP_SECRET = "oHVHR6VZFvAp#";
    public static final String PARAMKEY_APP_SECRET = "appSecret";
    public static final String PARAMKEY_TOKEN = "token";
    private UserInfo userInfo = MyApplication.getInstance().getLoginUser();
    @Override
    public void doLogin(String userName, String passWord, final OnLoginListener onLoginListener) {
        //使用OKhttp请求网络

        String url = AuroraConstants.LOG_IN_URL;
        OkHttpUtils
                .post()//
                .url(url)//
                .addParams("name", userName)//
                .addParams("pwd", passWord)//
                .addParams(PARAMKEY_TOKEN, "")//
                .addParams(PARAMKEY_APP_KEY, APP_KEY)//
                .addParams(PARAMKEY_APP_SECRET,"")//登录没secret

                .build()//
                .execute(new StringCallback()
                {
                    @Override
                    public void onError(Call call, Exception e, int id)
                    {
                        // onLoginListener.onLoginFail(e.getMessage());
                        Log.d(TAG,"连接失败");
                        onLoginListener.onLoginSuccess(null);
                    }

                    @Override
                    public void onResponse(String response, int id) {
                        Log.d(TAG,response);
                        Gson gson = new Gson();
                        LoginResultData d = gson.fromJson(response,LoginResultData.class);
                        if(d==null){
                            onLoginListener.onLoginFail("json解析错误");
                        }else if(d.isSuccess()){
                            onLoginListener.onLoginSuccess(d);
                        }else{
                            onLoginListener.onLoginFail(d.getMsg());
                        }

                    }
                });

    }

    @Override
    public void sendWorkLog(SendLogBean logData, final OnSendLogListener onSendLogListener) {
        Map<String,String> params = new HashMap<>();
        //发送没图片的报销

        params.put("completed", logData.completed==null?"":logData.completed);
        params.put("attachmentids", logData.attachmentids==null?"":logData.attachmentids);
        params.put("coordinated", logData.coordinated==null?"":logData.coordinated);
        params.put("remark", logData.remark==null?"":logData.remark);
        params.put("schedule", logData.schedule==null?"":logData.schedule);
        params.put("unfinished", logData.unfinished==null?"":logData.unfinished);
        params.put("userids", logData.userids==null?"":logData.userids);
        params.put("type", logData.type+"");
        postForm(AuroraConstants.SEND_LOG_URL, params, new OnRequestHttpDataListener() {
            @Override
            public void onRequestDataSuccess(String body) {
                Gson gson = new Gson();
                HttpResult result = gson.fromJson(body,HttpResult.class);
                if(result!=null&&result.success){
                    onSendLogListener.onSendLogSuccess(result);
                }else if(result==null){
                    onSendLogListener.onSendLogFail("解析错误");
                }else{
                    onSendLogListener.onSendLogFail(result.msg);
                }

            }

            @Override
            public void onRequestDataFail(String message) {
                onSendLogListener.onSendLogFail(message);
            }
        });
    }

    @Override
    public void requestHttpDataString(String url, final OnRequestHttpDataListener onRequestHttpDataListener) {
        //调用OKhttp框架请求数据
        String appSecret = "";
        if(userInfo!=null){
            appSecret = MD5Util.MD5(APP_SECRET + userInfo.getId());
        }

        OkHttpUtils
                .get()
                .addParams(PARAMKEY_TOKEN, SharedPreferencesUtil.getString(MyApplication.getInstance(),SharedPreferencesUtil.TOKEN))//自动登录
                .addParams(PARAMKEY_APP_KEY, APP_KEY)
                .addParams(PARAMKEY_APP_SECRET, appSecret)
                .url(url)
                .build()

                .execute(new StringCallback() {
                    @Override
                    public void onError(Call call, Exception e, int id) {
                        onRequestHttpDataListener.onRequestDataFail(e.getMessage());
                    }

                    @Override
                    public void onResponse(String response, int id) {
                        onRequestHttpDataListener.onRequestDataSuccess(response);
                    }
                });
    }

    //图片提交
    @Override
    public void postFile(String url, File file, final OnRequestHttpDataListener onRequestHttpDataListener) {
        String appSecret = "";
        if(userInfo!=null){
            appSecret = MD5Util.MD5(APP_SECRET + userInfo.getId());
        }
        OkHttpUtils
                .post()
                .addParams(PARAMKEY_TOKEN, SharedPreferencesUtil.getString(MyApplication.getInstance(),SharedPreferencesUtil.TOKEN))//自动登录
                .addParams(PARAMKEY_APP_KEY, APP_KEY)
                .addParams(PARAMKEY_APP_SECRET, appSecret)
                .url(url)
                .addFile("attachment", file.getPath().substring(file.getPath().lastIndexOf("/")+1,file.getPath().length()), file)
                .build()
                .execute(new StringCallback() {
                    @Override
                    public void onError(Call call, Exception e, int id) {
                        onRequestHttpDataListener.onRequestDataFail(e.getMessage());
                    }

                    @Override
                    public void onResponse(String response, int id) {
                        onRequestHttpDataListener.onRequestDataSuccess(response);
                    }
                });
    }

    //表单提交
    @Override
    public void postForm(String Url, Map<String, String> params, final OnRequestHttpDataListener onRequestHttpDataListener) {
        String appSecret = "";
        if(userInfo!=null){
            appSecret = MD5Util.MD5(APP_SECRET + userInfo.getId());
        }
        params.put(PARAMKEY_TOKEN, SharedPreferencesUtil.getString(MyApplication.getInstance(),SharedPreferencesUtil.TOKEN));
        params.put(PARAMKEY_APP_KEY, APP_KEY);
        params.put(PARAMKEY_APP_SECRET, appSecret);
        OkHttpUtils.post()//
                .url(Url)
                .params(params)//
                .build()//
                .execute(new StringCallback() {
                    @Override
                    public void onError(Call call, Exception e, int id) {
                        onRequestHttpDataListener.onRequestDataFail(e.getMessage());
                    }

                    @Override
                    public void onResponse(String response, int id) {
                        onRequestHttpDataListener.onRequestDataSuccess(response);
                    }
                });
    }

    @Override
    public void uploadAttachment(File file, final OnUploadAttachmentListener onUploadAttachmentListener) {
        postFile(AuroraConstants.POST_FILE_URL, file, new OnRequestHttpDataListener() {
            @Override
            public void onRequestDataSuccess(String body) {
                Gson gson = new Gson();
                ResponseFileID attachId =  gson.fromJson(body,ResponseFileID.class);
                if(attachId==null){
                    onUploadAttachmentListener.onUploadAttachmentFail("解析错误");
                }else if (!attachId.isSuccess()){
                    onUploadAttachmentListener.onUploadAttachmentFail("服务器返回false");
                }else{
                    onUploadAttachmentListener.onUploadAttachmentSuccess(attachId);
                }
            }

            @Override
            public void onRequestDataFail(String message) {
                onUploadAttachmentListener.onUploadAttachmentFail(message);
            }
        });
    }

    @Override
    public void getCompanyStructureData(final OnRequestCompanyStructureDataListener onRequestCompanyStructureDataListener) {
        requestHttpDataString(AuroraConstants.GET_COMPANY_STRUCTURE_DATA_URL, new OnRequestHttpDataListener() {
            @Override
            public void onRequestDataSuccess(String body) {
                Log.e("log_data",body);
                Gson gson = new Gson();
                Type type = new TypeToken<List<CompanyStructureBean>>(){}.getType();
                List<CompanyStructureBean> result = gson.fromJson(body,type);
                if(result!=null){
                    onRequestCompanyStructureDataListener.onRequestCompanyStructureSuccess(result);
                }else{
                    onRequestCompanyStructureDataListener.onRequestCompanyStructureFail("解析错误");
                }

            }

            @Override
            public void onRequestDataFail(String message) {
                onRequestCompanyStructureDataListener.onRequestCompanyStructureFail(message);
            }
        });
    }

    /**
     *
     * @param day 格式：2017-03-09
     * @param onRequestLogListDataListener 回调
     */
    @Override
    public void getMySendWorkLogByDay(String day, final OnRequestLogListDataListener onRequestLogListDataListener) {
      String url = AuroraConstants.GET_MYSEND_LOG_BY_DAY+"/"+day;
        requestHttpDataString(url, new OnRequestHttpDataListener() {
            @Override
            public void onRequestDataSuccess(String body) {
                Log.e("logdata",body);
               Gson gson = new Gson();
                Type type = new TypeToken<HttpResult<List<WorkLogDataBean>>>(){}.getType();
                HttpResult<List<WorkLogDataBean>> result = gson.fromJson(body,type);
                if(result.obj!=null){
                    onRequestLogListDataListener.onRequestLogListDataSuccess(result.obj);
                }else{
                    onRequestLogListDataListener.onRequestLogListDataFail("解析错误");
                }

            }

            @Override
            public void onRequestDataFail(String message) {
                onRequestLogListDataListener.onRequestLogListDataFail(message);
            }
        });
    }

    @Override
    public void getMyReceiveWorkLog(final OnRequestLogListDataListener onRequestLogListDataListener) {
        String url = AuroraConstants.GET_MYRECEIVE_WORK_LOG;
        requestHttpDataString(url, new OnRequestHttpDataListener() {
            @Override
            public void onRequestDataSuccess(String body) {
                Log.e("logdata",body);
              //  {"msg":"查询成功","obj":[{"attachments":[],"completed":"test1做测试","coordinated":"无","createdate":1491890729,"id":"7c307daca7224fa2870bdbb86e2bd4f3","messageReadState":2,"modifytime":0,"remark":"继续努力?","schedule":"100%","structureName":"","structureid":0,"type":1,"unfinished":"无","userHeadImage":"attachment/image/bbe717ffd1624034bab3fceee989f6c8/20170411/files1491890779.png","userid":"bbe717ffd1624034bab3fceee989f6c8","username":"test1"}],"success":true}

                Gson gson = new Gson();
                Type type = new TypeToken<HttpResult<List<WorkLogDataBean>>>(){}.getType();
                HttpResult<List<WorkLogDataBean>> result = gson.fromJson(body,type);
                if(result!=null){
                    onRequestLogListDataListener.onRequestLogListDataSuccess(result.obj);
                }else{
                    onRequestLogListDataListener.onRequestLogListDataFail("解析错误");
                }

            }

            @Override
            public void onRequestDataFail(String message) {
                onRequestLogListDataListener.onRequestLogListDataFail(message);
            }
        });
    }

    @Override
    public void getApplyMainUIData(final OnRequestHttpDataListener listener) {
        String url =AuroraConstants.GET_APPROVAL_CENTER_DATA;
        requestHttpDataString(url, new OnRequestHttpDataListener() {
            @Override
            public void onRequestDataSuccess(String body) {
                Log.e("logdata",body);
                //  {"msg":"查询成功","obj":[{"attachments":[],"completed":"test1做测试","coordinated":"无","createdate":1491890729,"id":"7c307daca7224fa2870bdbb86e2bd4f3","messageReadState":2,"modifytime":0,"remark":"继续努力?","schedule":"100%","structureName":"","structureid":0,"type":1,"unfinished":"无","userHeadImage":"attachment/image/bbe717ffd1624034bab3fceee989f6c8/20170411/files1491890779.png","userid":"bbe717ffd1624034bab3fceee989f6c8","username":"test1"}],"success":true}
                listener.onRequestDataSuccess(body);
         /*       Gson gson = new Gson();
                Type type = new TypeToken<HttpResult<List<WorkLogDataBean>>>(){}.getType();
                HttpResult<List<WorkLogDataBean>> result = gson.fromJson(body,type);
                if(result!=null){
                    onRequestLogListDataListener.onRequestLogListDataSuccess(result.obj);
                }else{
                    onRequestLogListDataListener.onRequestLogListDataFail("解析错误");
                }*/

            }

            @Override
            public void onRequestDataFail(String message) {
                listener.onRequestDataFail(message);
            }
        });
    }

    @Override
    public void getNoticeListData(int whitchPage, final OnRequestNoticeListListener onRequestNoticeListListener) {
        ///notice/page/{nowpage}
        String url = AuroraConstants.GET_NOTICE_LIST+"/"+whitchPage;
        requestHttpDataString(url, new OnRequestHttpDataListener() {
            @Override
            public void onRequestDataSuccess(String body) {
                Log.e("NOTICE_LIST_DATA",body);
                //  {"msg":"查询成功","obj":[{"attachments":[],"completed":"test1做测试","coordinated":"无","createdate":1491890729,"id":"7c307daca7224fa2870bdbb86e2bd4f3","messageReadState":2,"modifytime":0,"remark":"继续努力?","schedule":"100%","structureName":"","structureid":0,"type":1,"unfinished":"无","userHeadImage":"attachment/image/bbe717ffd1624034bab3fceee989f6c8/20170411/files1491890779.png","userid":"bbe717ffd1624034bab3fceee989f6c8","username":"test1"}],"success":true}

               Gson gson = new Gson();
                Type type = new TypeToken<HttpResult<List<NoticeBean>>>(){}.getType();
                HttpResult<List<NoticeBean>> result = gson.fromJson(body,type);
                if(result!=null){
                    onRequestNoticeListListener.onRequestNoticeListDataSuccess(result.obj);

                }else{
                    onRequestNoticeListListener.onRequestNoticeListDataFail("解析错误");
                }

            }

            @Override
            public void onRequestDataFail(String message) {
                onRequestNoticeListListener.onRequestNoticeListDataFail(message);
            }
        });
    }

    @Override
    public void getNoticeDetail(String id, final OnRequestNoticeDetailListener onRequestNoticeDetailListener) {
        String url = AuroraConstants.GET_NOTICE_DETAIL+"/"+id;
        requestHttpDataString(url, new OnRequestHttpDataListener() {
            @Override
            public void onRequestDataSuccess(String body) {
                onRequestNoticeDetailListener.onRequestNoticeDetailListenerSuccess(body);

            }

            @Override
            public void onRequestDataFail(String message) {
                onRequestNoticeDetailListener.onRequestNoticeDetailListenerFail(message);
            }
        });
    }

    @Override
    public void getLogDetail(String id, final OnRequestLogDetailListener onRequestLogDetailListener) {
        String url = AuroraConstants.GET_WORK_LOG_DETAIL+"/"+id;
        requestHttpDataString(url, new OnRequestHttpDataListener() {
            @Override
            public void onRequestDataSuccess(String body) {
                Log.e("log_data",body);
                //  {"msg":"查询成功","obj":[{"attachments":[],"completed":"test1做测试","coordinated":"无","createdate":1491890729,"id":"7c307daca7224fa2870bdbb86e2bd4f3","messageReadState":2,"modifytime":0,"remark":"继续努力?","schedule":"100%","structureName":"","structureid":0,"type":1,"unfinished":"无","userHeadImage":"attachment/image/bbe717ffd1624034bab3fceee989f6c8/20170411/files1491890779.png","userid":"bbe717ffd1624034bab3fceee989f6c8","username":"test1"}],"success":true}

                Gson gson = new Gson();
                Type type = new TypeToken<HttpResult<WorkLogDataBean>>(){}.getType();
                HttpResult<WorkLogDataBean> result = gson.fromJson(body,type);
                if(result!=null){
                    onRequestLogDetailListener.onRequestLogDetailSuccess(result.obj);
                }else{
                    onRequestLogDetailListener.onRequestLogDetailFail("解析错误");

                }

            }

            @Override
            public void onRequestDataFail(String message) {
                onRequestLogDetailListener.onRequestLogDetailFail(message);
            }
        });
    }

    @Override
    public void getExpenceDetail(String id, final OnRequestExpenceDetailListener onRequestExpenceDetailListener) {
        String url = AuroraConstants.GET_EXPENCE_DETAIL+"/"+id;
        requestHttpDataString(url, new OnRequestHttpDataListener() {
            @Override
            public void onRequestDataSuccess(String body) {
                Log.e("log_data",body);
                //  {"msg":"查询成功","obj":[{"attachments":[],"completed":"test1做测试","coordinated":"无","createdate":1491890729,"id":"7c307daca7224fa2870bdbb86e2bd4f3","messageReadState":2,"modifytime":0,"remark":"继续努力?","schedule":"100%","structureName":"","structureid":0,"type":1,"unfinished":"无","userHeadImage":"attachment/image/bbe717ffd1624034bab3fceee989f6c8/20170411/files1491890779.png","userid":"bbe717ffd1624034bab3fceee989f6c8","username":"test1"}],"success":true}

                Gson gson = new Gson();
                Type type = new TypeToken<HttpResult<ExpenceBean>>(){}.getType();
                HttpResult<ExpenceBean> result = gson.fromJson(body,type);
                if(result!=null){
                    onRequestExpenceDetailListener.onRequestExpenceDetailSuccess(result.obj);
                }else{
                    onRequestExpenceDetailListener.onRequestExpenceDetailFail("解析失败");
                }
            }

            @Override
            public void onRequestDataFail(String message) {
                onRequestExpenceDetailListener.onRequestExpenceDetailFail(message);
            }
        });
    }

    @Override
    public void getApproveListData(int whitchPage, int type, final OnRequestApproveListListener onRequestApproveListListener) {
            ///flow_user/getMyReceived/1?approvalState=2 审核状态（1未审核2审核通过3审核不通过）
        String url = AuroraConstants.GET_APPROVE_LIST_DATA+"/"+whitchPage+"?approvalState="+type;
        requestHttpDataString(url, new OnRequestHttpDataListener() {
            @Override
            public void onRequestDataSuccess(String body) {
                Log.e("log_data",body);
                //  {"msg":"查询成功","obj":[{"attachments":[],"completed":"test1做测试","coordinated":"无","createdate":1491890729,"id":"7c307daca7224fa2870bdbb86e2bd4f3","messageReadState":2,"modifytime":0,"remark":"继续努力?","schedule":"100%","structureName":"","structureid":0,"type":1,"unfinished":"无","userHeadImage":"attachment/image/bbe717ffd1624034bab3fceee989f6c8/20170411/files1491890779.png","userid":"bbe717ffd1624034bab3fceee989f6c8","username":"test1"}],"success":true}

                Gson gson = new Gson();
                Type type = new TypeToken<HttpResult<List<ApproveListBean>>>(){}.getType();
                HttpResult<List<ApproveListBean>> result = gson.fromJson(body,type);
                if(result!=null){
                    onRequestApproveListListener.OnRequestApproveListSuccess(result.obj);
                }else{
                    onRequestApproveListListener.OnRequestApproveListFail("解析失败");

                }
            }

            @Override
            public void onRequestDataFail(String message) {
                onRequestApproveListListener.OnRequestApproveListFail(message);
            }
        });
    }

    @Override
    public void getApproveDetail(String id, final OnGetApproveDetailListener onGetApproveDetailListener) {
        String url = AuroraConstants.GET_APPROVE_DETAIL+"/"+id;
        requestHttpDataString(url, new OnRequestHttpDataListener() {
            @Override
            public void onRequestDataSuccess(String body) {
                Log.e("log_data",body);
                ApproveDataBean approveDataBean = new ApproveDataBean();
                try {
                    JSONObject jsonObject = new JSONObject(body);
                    //数据请求成功向下解析
                    if(jsonObject.optBoolean("success",false)){
                        JSONObject dataJson = jsonObject.optJSONObject("obj");
                        JSONArray jsonArray = dataJson.optJSONArray("list1");
                        List<ApproveDataBean.CommonContent> commonContentList = new ArrayList<>();
                        for(int i = 0,length = jsonArray.length();i<length;i++){
                            //第一条是头数据
                            JSONObject itemData = jsonArray.getJSONObject(i);
                            if(i==0){
                                ApproveDataBean.HeadDataBean headDataBean= approveDataBean.new HeadDataBean();
                                headDataBean.setApprovalState(itemData.optInt("approvalState",0));
                                headDataBean.setCreateTime(itemData.optString("createTime",""));
                                headDataBean.setIco(itemData.optString("ico",""));
                                headDataBean.setName(itemData.optString("name",""));
                                headDataBean.setPostName(itemData.optString("postName",""));
                                approveDataBean.setHeadDataBean(headDataBean);
                                //附件数据
                            }else if(itemData.optString("title","").equals("附件")){
                                ApproveDataBean.AttachContent attachContent = approveDataBean.new AttachContent();
                                List<String> urlList = new ArrayList<>();
                                attachContent.setTitle(itemData.optString("title",""));
                                JSONArray attachData = itemData.optJSONArray("value");
                                for(int j=0;j<attachData.length();j++){
                                    urlList.add(attachData.optString(j));
                                }
                                attachContent.setUrl(urlList);
                                approveDataBean.setAttachContentBean(attachContent);
                                //普通内容，标题内容
                            }else{
                                ApproveDataBean.CommonContent commonContent =approveDataBean.new CommonContent();
                                commonContent.setTitle(itemData.optString("title",""));
                                commonContent.setValue(itemData.optString("value",""));
                                commonContentList.add(commonContent);
                            }
                        }
                        approveDataBean.setCommonContentBeanList(commonContentList);


                        //解析审批流数据
                        JSONObject flowJsonObject = dataJson.optJSONObject("list2");
                        ApproveDataBean.ApproveFlow flowContent = approveDataBean.new ApproveFlow();
                        List<ApproveDataBean.ApproveFlow.FlowData> flowDataList = new ArrayList<>();
                        flowContent.setTitle(flowJsonObject.optString("title",""));
                        JSONArray flowData = flowJsonObject.optJSONArray("value");
                            for(int j=0;j<flowData.length();j++){
                                JSONObject flowItemJData = jsonArray.getJSONObject(j);
                                ApproveDataBean.ApproveFlow.FlowData flowItemData =flowContent.new FlowData();
                                flowItemData.setApproveName(flowItemJData.optString("approverName",""));
                                flowItemData.setApproveTime(flowItemJData.optString("approvalTime",""));
                                flowItemData.setApproveState(flowItemJData.optInt("approvalState",0));
                                flowItemData.setApprovalRemark(flowItemJData.optString("approvalRemark",""));
                                flowItemData.setApprovalHeadImage(flowItemJData.optString("approvalHeadImage",""));
                                flowDataList.add(flowItemData);
                            }
                            flowContent.setFlowDataList(flowDataList);
                            approveDataBean.setApproveFlowBean(flowContent);

                        onGetApproveDetailListener.onGetApproveDetailSuccess(approveDataBean);
                    }else{
                        onGetApproveDetailListener.onGetApproveDetailFail("数据请求失败");
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                    onGetApproveDetailListener.onGetApproveDetailFail("解析失败");
                }
            }

            @Override
            public void onRequestDataFail(String message) {
                onGetApproveDetailListener.onGetApproveDetailFail(message);
            }
        });
    }

    @Override
    public void doApproveTransfer(String id, String transferIds, OnRequestHttpDataListener onRequestHttpDataListener) {
       String url = AuroraConstants.DO_APPROVE_TRANSFER+"/"+id;
     //   transfer
        Map<String,String> params = new HashMap<>();
        params.put("transfer",transferIds);
        postForm(url,params,onRequestHttpDataListener);
    }

    @Override
    public void doApproveAgree(String id, int state, OnRequestHttpDataListener onRequestHttpDataListener) {
        String url = AuroraConstants.DO_APPROVE+"/"+id;
        //   transfer
        Map<String,String> params = new HashMap<>();
        params.put("approvalState",state+"");
        postForm(url,params,onRequestHttpDataListener);
    }

    @Override
    public void doApproveDeni(String id, int state, OnRequestHttpDataListener onRequestHttpDataListener) {
        String url = AuroraConstants.DO_APPROVE+"/"+id;
        //   transfer
        Map<String,String> params = new HashMap<>();
        params.put("approvalState",state+"");
        postForm(url,params,onRequestHttpDataListener);
    }

    @Override
    public void doApproveComment(String id, String content, OnRequestHttpDataListener onRequestHttpDataListener) {
        String url = AuroraConstants.DO_APPROVE_COMMENT+"/"+id;
        //   transfer
        Map<String,String> params = new HashMap<>();
        params.put("remark",content);
        postForm(url,params,onRequestHttpDataListener);
    }

    @Override
    public void getDailyData(final OnRequestDailyDataListener onRequestDailyDataListener) {
        String url = AuroraConstants.GET_DAILY_DATA;
        requestHttpDataString(url, new OnRequestHttpDataListener() {
            @Override
            public void onRequestDataSuccess(String body) {
                Log.e("log_data",body);
                //  {"msg":"查询成功","obj":[{"attachments":[],"completed":"test1做测试","coordinated":"无","createdate":1491890729,"id":"7c307daca7224fa2870bdbb86e2bd4f3","messageReadState":2,"modifytime":0,"remark":"继续努力?","schedule":"100%","structureName":"","structureid":0,"type":1,"unfinished":"无","userHeadImage":"attachment/image/bbe717ffd1624034bab3fceee989f6c8/20170411/files1491890779.png","userid":"bbe717ffd1624034bab3fceee989f6c8","username":"test1"}],"success":true}

                Gson gson = new Gson();
                Type type = new TypeToken<HttpResult<DailyDataBean>>(){}.getType();
                HttpResult<DailyDataBean> result = gson.fromJson(body,type);
                if(result!=null){
                    onRequestDailyDataListener.onRequestDailyDataSuccess(result.obj);

                }else{
                    onRequestDailyDataListener.onRequestDailyDataFail("解析失败");

                }
            }

            @Override
            public void onRequestDataFail(String message) {
                onRequestDailyDataListener.onRequestDailyDataFail(message);
            }
        });

    }

    @Override
    public void getAttendancePerson(final OnRequestAttendancePersonListener onRequestHttpDataListener) {
        String url = AuroraConstants.GET_TODAY_SIGNUSER;
        requestHttpDataString(url, new OnRequestHttpDataListener() {
            @Override
            public void onRequestDataSuccess(String body) {
                Log.e("log_data",body);
                //  {"msg":"查询成功","obj":[{"attachments":[],"completed":"test1做测试","coordinated":"无","createdate":1491890729,"id":"7c307daca7224fa2870bdbb86e2bd4f3","messageReadState":2,"modifytime":0,"remark":"继续努力?","schedule":"100%","structureName":"","structureid":0,"type":1,"unfinished":"无","userHeadImage":"attachment/image/bbe717ffd1624034bab3fceee989f6c8/20170411/files1491890779.png","userid":"bbe717ffd1624034bab3fceee989f6c8","username":"test1"}],"success":true}

                Gson gson = new Gson();
                Type type = new TypeToken<HttpResult<List<UserInfo>>>(){}.getType();
                HttpResult<List<UserInfo>> result = gson.fromJson(body,type);
                if(result!=null&&result.success){
                    onRequestHttpDataListener.onRequestAttendancePersonSuccess(result.obj);
                }else{
                    onRequestHttpDataListener.onRequestAttendancePersonFail("解析错误");

                }
            }

            @Override
            public void onRequestDataFail(String message) {
                onRequestHttpDataListener.onRequestAttendancePersonFail(message);
            }
        });
    }

    @Override
    public void getUserMonthData(String userId, String currentDate, OnRequestHttpDataListener onRequestHttpDataListener) {
        String url = AuroraConstants.GET_USER_MONTH_DATA+"/"+userId+"/"+currentDate;
        requestHttpDataString(url,onRequestHttpDataListener);
    }

    @Override
    public void getApplyListData(int whitchPage, final OnRequestApplyListListener onRequestApplyListListener) {
        String url = AuroraConstants.GET_APPLY_LIST_DATA+"/"+whitchPage+"?approvalState=";
        requestHttpDataString(url, new OnRequestHttpDataListener() {
            @Override
            public void onRequestDataSuccess(String body) {
                Log.e("log_data",body);
                //  {"msg":"查询成功","obj":[{"attachments":[],"completed":"test1做测试","coordinated":"无","createdate":1491890729,"id":"7c307daca7224fa2870bdbb86e2bd4f3","messageReadState":2,"modifytime":0,"remark":"继续努力?","schedule":"100%","structureName":"","structureid":0,"type":1,"unfinished":"无","userHeadImage":"attachment/image/bbe717ffd1624034bab3fceee989f6c8/20170411/files1491890779.png","userid":"bbe717ffd1624034bab3fceee989f6c8","username":"test1"}],"success":true}

                Gson gson = new Gson();
                Type type = new TypeToken<HttpResult<List<ApplyListBean>>>(){}.getType();
                HttpResult<List<ApplyListBean>> result = gson.fromJson(body,type);
                if(result!=null){
                    onRequestApplyListListener.OnRequestApplyListSuccess(result.obj);
                }else{
                    onRequestApplyListListener.OnRequestApplyListFail("解析失败");
                }
            }

            @Override
            public void onRequestDataFail(String message) {
                onRequestApplyListListener.OnRequestApplyListFail(message);
            }
        });
    }

    @Override
    public void getCarListData(int whitchPage, final OnRequestCarListListener onRequestCarListListener) {
        String url = AuroraConstants.GET_APPLY_CAR_LIST_DATA+"/"+whitchPage;
        requestHttpDataString(url, new OnRequestHttpDataListener() {
            @Override
            public void onRequestDataSuccess(String body) {
                Log.e("log_data",body);
                //  {"msg":"查询成功","obj":[{"attachments":[],"completed":"test1做测试","coordinated":"无","createdate":1491890729,"id":"7c307daca7224fa2870bdbb86e2bd4f3","messageReadState":2,"modifytime":0,"remark":"继续努力?","schedule":"100%","structureName":"","structureid":0,"type":1,"unfinished":"无","userHeadImage":"attachment/image/bbe717ffd1624034bab3fceee989f6c8/20170411/files1491890779.png","userid":"bbe717ffd1624034bab3fceee989f6c8","username":"test1"}],"success":true}

                Gson gson = new Gson();
                Type type = new TypeToken<HttpResult<List<ApplyCarBean>>>(){}.getType();
                HttpResult<List<ApplyCarBean>> result = gson.fromJson(body,type);
                if(result.success){
                    onRequestCarListListener.onRequestCarListSuccess(result.obj);
                }else{
                    onRequestCarListListener.onRequestCarListFail("获取数据失败");
                }
            }

            @Override
            public void onRequestDataFail(String message) {
                onRequestCarListListener.onRequestCarListFail(message);
            }
        });
    }

    @Override
    public void getPatrollogListData(String month_date, final OnRequestPatrollogListListener onRequestPatrollogListListener) {
        String url = AuroraConstants.GET_PATROLLOG_LIST_DATA+"/"+month_date;
        requestHttpDataString(url, new OnRequestHttpDataListener() {
            @Override
            public void onRequestDataSuccess(String body) {
                Log.e("log_data",body);
                Gson gson = new Gson();
                Type type = new TypeToken<HttpResult<List<PatrollogListBean>>>(){}.getType();
                HttpResult<List<PatrollogListBean>> result = gson.fromJson(body,type);
                if(result.success){
                    onRequestPatrollogListListener.onRequestPatrollogListSuccess(result.obj);
                }else{
                    onRequestPatrollogListListener.onRequestPatrollogListFail("获取数据失败");
                }
            }

            @Override
            public void onRequestDataFail(String message) {
                onRequestPatrollogListListener.onRequestPatrollogListFail(message);
            }
        });
    }

    @Override
    public void getPatrollogDetail(String id, final OnRequestPatrollogDetailListener onRequestPatrollogDetailListener) {
        String url = AuroraConstants.GET_PATROLLOG_DETAIL+"/"+id;
        requestHttpDataString(url, new OnRequestHttpDataListener() {
            @Override
            public void onRequestDataSuccess(String body) {
                Log.e("log_data",body);
                Gson gson = new Gson();
                Type type = new TypeToken<HttpResult<PatrollogBean>>(){}.getType();
                HttpResult<PatrollogBean> result = gson.fromJson(body,type);
                if(result.success){
                    onRequestPatrollogDetailListener.onRequestPatrollogDetailSuccess(result.obj);
                }else{
                    onRequestPatrollogDetailListener.onRequestPatrollogDetailFail("获取数据失败");
                }
            }

            @Override
            public void onRequestDataFail(String message) {
                onRequestPatrollogDetailListener.onRequestPatrollogDetailFail(message);
            }
        });
    }

    @Override
    public void sendPatrollog(SendPatrollogBean logData, final OnSendPatrollogListener onSendPatrollogListener) {
        Map<String,String> params = new HashMap<>();
        params.put("shopname", logData.shopname==null?"":logData.shopname);
        params.put("shopid", logData.shopid==null?"":logData.shopid);
        params.put("sales", logData.sales==null?"":logData.sales);
        params.put("remark", logData.remark==null?"":logData.remark);
        params.put("attachmentids", logData.attachmentids==null?"":logData.attachmentids);
        postForm(AuroraConstants.SEND_PATROLLOG_URL, params, new OnRequestHttpDataListener() {
            @Override
            public void onRequestDataSuccess(String body) {
                Gson gson = new Gson();
                HttpResult result = gson.fromJson(body,HttpResult.class);
                if(result!=null&&result.success){
                    onSendPatrollogListener.onSendPatrollogSuccess(result);
                }else if(result==null){
                    onSendPatrollogListener.onSendPatrollogFail("解析错误");
                }else{
                    onSendPatrollogListener.onSendPatrollogFail(result.msg);
                }

            }

            @Override
            public void onRequestDataFail(String message) {
                onSendPatrollogListener.onSendPatrollogFail(message);
            }
        });
    }

    @Override
    public void getPatrolShopListData(final OnRequestPatrolShopListListener onRequestPatrolShopListListener) {
        String url = AuroraConstants.GET_PATROLSHOP_LIST_DATA;
        requestHttpDataString(url, new OnRequestHttpDataListener() {
            @Override
            public void onRequestDataSuccess(String body) {
                Log.e("log_data",body);
                Gson gson = new Gson();
                Type type = new TypeToken<HttpResult<List<PatrolShopListBean>>>(){}.getType();
                HttpResult<List<PatrolShopListBean>> result = gson.fromJson(body,type);
                if(result.success){
                    onRequestPatrolShopListListener.onRequestPatrolShopListSuccess(result.obj);
                }else{
                    onRequestPatrolShopListListener.onRequestPatrolShopListFail(result.msg);
                }
            }

            @Override
            public void onRequestDataFail(String message) {
                onRequestPatrolShopListListener.onRequestPatrolShopListFail(message);
            }
        });
    }

    @Override
    public void getPatrollogListByShopAndDay(String shopid, String currentDate, final OnRequestPatrollogListListener onRequestPatrollogListListener) {
        String url = AuroraConstants.GET_LOGLIST_BY_SHOPID_AND_DATE+"/"+shopid+"/"+currentDate;
        requestHttpDataString(url, new OnRequestHttpDataListener() {
            @Override
            public void onRequestDataSuccess(String body) {
                Log.e("log_data",body);
                Gson gson = new Gson();
                Type type = new TypeToken<HttpResult<List<PatrollogListBean>>>(){}.getType();
                HttpResult<List<PatrollogListBean>> result = gson.fromJson(body,type);
                if(result.success){
                    onRequestPatrollogListListener.onRequestPatrollogListSuccess(result.obj);
                }else{
                    onRequestPatrollogListListener.onRequestPatrollogListFail(result.msg);
                }
            }

            @Override
            public void onRequestDataFail(String message) {
                onRequestPatrollogListListener.onRequestPatrollogListFail(message);
            }
        });
    }

    @Override
    public void doAddTeam(String teamName, final OnAddTeamListener onAddTeamListener) {
        Map<String,String> params = new HashMap<>();
        //发送没图片的报销
        params.put("name", teamName==null?"":teamName);
        postForm(AuroraConstants.DO_TEAM_ADD, params, new OnRequestHttpDataListener() {
            @Override
            public void onRequestDataSuccess(String body) {
                Gson gson = new Gson();
                HttpResult result = gson.fromJson(body,HttpResult.class);
                if(result!=null&&result.success){
                    onAddTeamListener.onAddTeamSuccess();
                }else if(result==null){
                    onAddTeamListener.onAddTeamFail("解析错误");
                }else{
                    onAddTeamListener.onAddTeamFail(result.msg);
                }

            }

            @Override
            public void onRequestDataFail(String message) {
                onAddTeamListener.onAddTeamFail(message);
            }
        });
    }

    @Override
    public void doAddContactsGroup(String contactsName, final OnAddContactsGroupListener onAddContactsGroupListener) {
        Map<String,String> params = new HashMap<>();
        //发送没图片的报销
        params.put("name", contactsName==null?"":contactsName);
        postForm(AuroraConstants.DO_CONTACTS_GROUP_ADD, params, new OnRequestHttpDataListener() {
            @Override
            public void onRequestDataSuccess(String body) {
                Gson gson = new Gson();
                HttpResult result = gson.fromJson(body,HttpResult.class);
                if(result!=null&&result.success){
                    onAddContactsGroupListener.onAddContactsGroupSuccess();
                }else if(result==null){
                    onAddContactsGroupListener.onAddContactsGroupFail("解析错误");
                }else{
                    onAddContactsGroupListener.onAddContactsGroupFail(result.msg);
                }

            }

            @Override
            public void onRequestDataFail(String message) {
                onAddContactsGroupListener.onAddContactsGroupFail(message);
            }
        });
    }

    @Override
    public void getMyTeamList(final OnGetMyTeamListListener onGetMyTeamListListener) {
        String url = AuroraConstants.GET_MY_TEAM_LIST_DATE;
        requestHttpDataString(url, new OnRequestHttpDataListener() {
            @Override
            public void onRequestDataSuccess(String body) {
                Log.e("log_data",body);
                Gson gson = new Gson();
                Type type = new TypeToken<HttpResult<List<TeamBean>>>(){}.getType();
                HttpResult<List<TeamBean>> result = gson.fromJson(body,type);
                if(result.success){
                    onGetMyTeamListListener.onGetMyTeamListSuccess(result.obj);
                }else{
                    onGetMyTeamListListener.onGetMyTeamListFail(result.msg);
                }
            }

            @Override
            public void onRequestDataFail(String message) {
                onGetMyTeamListListener.onGetMyTeamListFail(message);
            }
        });
    }

    @Override
    public void getMyContactsGroupList(final OnGetMyContactsGroupListListener onGetMyContactsGroupListListener) {
        String url = AuroraConstants.GET_MY_CONTACTS_GROUP_LIST_DATE;
        requestHttpDataString(url, new OnRequestHttpDataListener() {
            @Override
            public void onRequestDataSuccess(String body) {
                Log.e("log_data",body);
                Gson gson = new Gson();
                Type type = new TypeToken<HttpResult<List<MyContactsGroupBean>>>(){}.getType();
                HttpResult<List<MyContactsGroupBean>> result = gson.fromJson(body,type);
                if(result.success){
                    onGetMyContactsGroupListListener.onGetMyContactsGroupListSuccess(result.obj);
                }else{
                    onGetMyContactsGroupListListener.onGetMyContactsGroupListFail(result.msg);
                }
            }

            @Override
            public void onRequestDataFail(String message) {
                onGetMyContactsGroupListListener.onGetMyContactsGroupListFail(message);
            }
        });
    }

    @Override
    public void getMyTeamMemBerList(String teamID, final OnGetMyTeamMemberListListener onGetMyTeamMemberListListener) {
        String url = AuroraConstants.GET_MY_TEAM_MEMBER_LIST_DATE+"/"+teamID;
        requestHttpDataString(url, new OnRequestHttpDataListener() {
            @Override
            public void onRequestDataSuccess(String body) {
                Log.e("log_data",body);
                Gson gson = new Gson();
                Type type = new TypeToken<HttpResult<List<TeamMemberBean>>>(){}.getType();
                HttpResult<List<TeamMemberBean>> result = gson.fromJson(body,type);
                if(result.success){
                    onGetMyTeamMemberListListener.onGetMyTeamMemberListSuccess(result.obj);
                }else{
                    onGetMyTeamMemberListListener.onGetMyTeamMemberListFail(result.msg);
                }
            }

            @Override
            public void onRequestDataFail(String message) {
                onGetMyTeamMemberListListener.onGetMyTeamMemberListFail(message);
            }
        });
    }

    @Override
    public void getMyContactsList(String contactsGroupID, final OnGetMyContactsListListener onGetMyContactsListListener) {
        String url = AuroraConstants.GET_MY_CONTACTS_LIST_DATE+"/"+contactsGroupID;
        requestHttpDataString(url, new OnRequestHttpDataListener() {
            @Override
            public void onRequestDataSuccess(String body) {
                Log.e("log_data",body);
                Gson gson = new Gson();
                Type type = new TypeToken<HttpResult<List<ContactsBean>>>(){}.getType();
                HttpResult<List<ContactsBean>> result = gson.fromJson(body,type);
                if(result.success){
                    onGetMyContactsListListener.onGetMyContactsListSuccess(result.obj);
                }else{
                    onGetMyContactsListListener.onGetMyContactsListFail(result.msg);
                }
            }

            @Override
            public void onRequestDataFail(String message) {
                onGetMyContactsListListener.onGetMyContactsListFail(message);
            }
        });
    }

    @Override
    public void doAddTeamMember(String teamid, String userids, final OnAddTeamMemberListener onAddTeamMemberListener) {
       // /teamuser/add
/*        teamid	string	团队ID
        userid	string	用户id（成员）
        remark	string	备注*/
        Map<String,String> params = new HashMap<>();
        //发送没图片的报销
        params.put("teamid", teamid==null?"":teamid);
        params.put("userid", userids==null?"":userids);
        postForm(AuroraConstants.DO_TEAM_MEMBER_ADD, params, new OnRequestHttpDataListener() {
            @Override
            public void onRequestDataSuccess(String body) {
                Gson gson = new Gson();
                HttpResult result = gson.fromJson(body,HttpResult.class);
                if(result!=null&&result.success){
                    onAddTeamMemberListener.onAddTeamMemberSuccess();
                }else if(result==null){
                    onAddTeamMemberListener.onAddTeamMemberFail("解析错误");
                }else{
                    onAddTeamMemberListener.onAddTeamMemberFail(result.msg);
                }

            }

            @Override
            public void onRequestDataFail(String message) {
                onAddTeamMemberListener.onAddTeamMemberFail(message);
            }
        });
    }

    @Override
    public void doAddGroupMember(String groupid, String userids, final OnAddGroupMemberListener onAddGroupMemberListener) {
       // /contacts/add/{userid}/{groupid}
        String url = AuroraConstants.DO_GROUP_MEMBER_ADD+"/"+userids+"/"+groupid;
        requestHttpDataString(url, new OnRequestHttpDataListener() {
            @Override
            public void onRequestDataSuccess(String body) {
                Log.e("log_data",body);
                Gson gson = new Gson();
                HttpResult result = gson.fromJson(body,HttpResult.class);
                if(result!=null&&result.success){
                    onAddGroupMemberListener.onAddGroupMemberSuccess();
                }else if(result==null){
                    onAddGroupMemberListener.onAddGroupMemberFail("解析错误");
                }else{
                    onAddGroupMemberListener.onAddGroupMemberFail(result.msg);
                }
            }

            @Override
            public void onRequestDataFail(String message) {
                onAddGroupMemberListener.onAddGroupMemberFail(message);
            }
        });
    }

    @Override
    public void getUserInfo(String id, final OnGetUserInfoListener onGetUserInfoListener) {
        String url = AuroraConstants.GET_USER_INFO+"/"+id;
        requestHttpDataString(url, new OnRequestHttpDataListener() {
            @Override
            public void onRequestDataSuccess(String body) {
                Log.e("log_data",body);
                Gson gson = new Gson();
                Type type = new TypeToken<HttpResult<UserInfo>>(){}.getType();
                HttpResult<UserInfo> result = gson.fromJson(body,type);
                if(result!=null&&result.success){
                    onGetUserInfoListener.onGetUserInfoSuccess(result.obj);
                }else if(result==null){
                    onGetUserInfoListener.onGetUserInfoFail("解析错误");
                }else{
                    onGetUserInfoListener.onGetUserInfoFail(result.msg);
                }
            }

            @Override
            public void onRequestDataFail(String message) {
                onGetUserInfoListener.onGetUserInfoFail(message);
            }
        });
    }

    @Override
    public void doHeadUpload(String attachId, final OnRequestHttpDataListener onRequestHttpDataListener) {
        String url = AuroraConstants.UPDATE_USER_HEADIMG+"/"+attachId;
        requestHttpDataString(url, new OnRequestHttpDataListener() {
            @Override
            public void onRequestDataSuccess(String body) {
                Log.e("log_data",body);
                onRequestHttpDataListener.onRequestDataSuccess(body);
            }

            @Override
            public void onRequestDataFail(String message) {
                onRequestHttpDataListener.onRequestDataFail(message);
            }
        });
    }

    @Override
    public void doUpdateUserInfo(Map<String, String> params, final OnRequestIsSuccessListener onRequestIsSuccessListener) {
        postForm(AuroraConstants.DO_USER_INFO_UPDATE, params, new OnRequestHttpDataListener() {
            @Override
            public void onRequestDataSuccess(String body) {
                Gson gson = new Gson();
                HttpResult result = gson.fromJson(body,HttpResult.class);
                if(result!=null&&result.success){
                    onRequestIsSuccessListener.onRequestSuccess(result.msg);
                }else if(result==null){
                    onRequestIsSuccessListener.onRequestFail("解析错误");
                }else{
                    onRequestIsSuccessListener.onRequestFail(result.msg);
                }

            }

            @Override
            public void onRequestDataFail(String message) {
                onRequestIsSuccessListener.onRequestFail(message);
            }
        });
    }

    @Override
    public void getApplyCarHistoryData(int whitchPage, final OnRequestCarHistoryListener onRequestCarHistoryListener) {
        String url = AuroraConstants.GET_APPLY_CAR_HISTORY_DATA+"/"+whitchPage;
        requestHttpDataString(url, new OnRequestHttpDataListener() {
            @Override
            public void onRequestDataSuccess(String body) {
                Log.e("log_data",body);
                Gson gson = new Gson();
                Type type = new TypeToken<HttpResult<List<ApplyCarHistoryBean>>>(){}.getType();
                HttpResult<List<ApplyCarHistoryBean>> result = gson.fromJson(body,type);
                if(result.success){
                    onRequestCarHistoryListener.onRequestCarHistorySuccess(result.obj);
                }else{
                    onRequestCarHistoryListener.onRequestCarHistoryFail(result.msg);
                }
            }

            @Override
            public void onRequestDataFail(String message) {
                onRequestCarHistoryListener.onRequestCarHistoryFail(message);
            }
        });
    }

    /**
     *
     * @param yearmonth 201112
     * @param onRequestTrackHistoryListener
     */
    @Override
    public void getTrackHistoryData(String yearmonth, final OnRequestTrackHistoryListener onRequestTrackHistoryListener) {
        String url = AuroraConstants.GET_TRACK_HISTORY_DATA_MONTH+"/"+yearmonth;
        requestHttpDataString(url, new OnRequestHttpDataListener() {
            @Override
            public void onRequestDataSuccess(String body) {
                Log.e("log_data",body);
                Gson gson = new Gson();
                Type type = new TypeToken<HttpResult<List<TrackHistoryBean>>>(){}.getType();
                HttpResult<List<TrackHistoryBean>> result = gson.fromJson(body,type);
                if(result.success){
                    onRequestTrackHistoryListener.onRequestTrackHistorySuccess(result.obj);
                }else{
                    onRequestTrackHistoryListener.onRequestTrackHistoryFail(result.msg);
                }
            }

            @Override
            public void onRequestDataFail(String message) {
                onRequestTrackHistoryListener.onRequestTrackHistoryFail(message);
            }
        });
    }

    @Override
    public void doSignComment(String id, String input, final OnRequestIsSuccessListener onRequestIsSuccessListener) {
       String url = AuroraConstants.DO_SIGN_COMMENT +"/"+id;
        Map<String,String> params = new HashMap<>();
        //发送没图片的报销
        params.put("remark", input==null?"":input);
        postForm(url, params, new OnRequestHttpDataListener() {
            @Override
            public void onRequestDataSuccess(String body) {
                Gson gson = new Gson();
                HttpResult result = gson.fromJson(body,HttpResult.class);
                if(result.success) {
                    onRequestIsSuccessListener.onRequestSuccess(result.msg);
                }else{
                    onRequestIsSuccessListener.onRequestFail(result.msg);
                }

            }

            @Override
            public void onRequestDataFail(String message) {
                onRequestIsSuccessListener.onRequestFail(message);
            }
        });
    }

    @Override
    public void getFileListData(int whitchPage, final OnRequestFileListListener onRequestFileListListener) {
        String url = AuroraConstants.GET_COMPANY_FILES+"/"+whitchPage;
        requestHttpDataString(url, new OnRequestHttpDataListener() {
            @Override
            public void onRequestDataSuccess(String body) {
                Log.e("log_data",body);
                Gson gson = new Gson();
                Type type = new TypeToken<HttpResult<List<FileBean>>>(){}.getType();
                HttpResult<List<FileBean>> result = gson.fromJson(body,type);
                if(result.success){
                    onRequestFileListListener.onRequestFileListSuccess(result.obj);
                }else{
                    onRequestFileListListener.onRequestFileListFail(result.msg);
                }
            }

            @Override
            public void onRequestDataFail(String message) {
                onRequestFileListListener.onRequestFileListFail(message);
            }
        });
    }

    @Override
    public void doSendFeedback(String title, String content, String attachmentids, final OnUploadFeedbackListener listener) {
        String url = AuroraConstants.DO_FEEDBACK_UPLOAD ;
        Map<String,String> params = new HashMap<>();
        //发送没图片的报销
        params.put("title", title==null?"":title);
        params.put("content", content==null?"":content);
        params.put("attachmentids", attachmentids==null?"":attachmentids);
        postForm(url, params, new OnRequestHttpDataListener() {
            @Override
            public void onRequestDataSuccess(String body) {
                Gson gson = new Gson();
                HttpResult result = gson.fromJson(body,HttpResult.class);
                if(result.success) {
                    listener.onUploadFeedbackSuccess();
                }else{
                    listener.onUploadFeedbackFail(result.msg);
                }

            }

            @Override
            public void onRequestDataFail(String message) {
                listener.onUploadFeedbackFail(message);
            }
        });
    }

    @Override
    public void getArticalDetail(String id, final OnRequestArticalDetailListener onRequestArticalDetailListener) {
        String url = AuroraConstants.GET_ARTICAL_DETAIL+"/"+id;
        requestHttpDataString(url, new OnRequestHttpDataListener() {
            @Override
            public void onRequestDataSuccess(String body) {
                onRequestArticalDetailListener.onRequestArticalDetailSuccess(body);
            }

            @Override
            public void onRequestDataFail(String message) {
                onRequestArticalDetailListener.onRequestArticalDetailFail(message);
            }
        });
    }


}
